const log4js = require("log4js");
const path = require("path");

const path = require("path");
// 定义log config
log4js.configure({
  appenders: {
    // 定义两个输出源
    info: { type: "file", filename: path.resolve("log/info.log") },
    error: { type: "file", filename: path.resolve("log/error.log") },
  },
  categories: {
    // 为info log调用info输出源   error 调用error输出源
    info: { appenders: ["info"], level: "info" },
    error: { appenders: ["error"], level: "error" },
  },
});
// 导出 logger
module.exports = {
  info: (...params) => log4js.getLogger("info").info(...params),
  error: (...params) => log4js.getLogger("error").error(...params),
};
